<?php
/**
 * Logger helper class
 * @author Danila V. (www.smartycode.com)
 * @version $Id: Logger.php 14 2009-10-26 06:36:37Z hami $
 *
 */
class Zend_Controller_Action_Helper_Logger extends Zend_Controller_Action_Helper_Abstract
{
	/**
	 * Logger instance
	 *
	 * @var Zend_Log The logger
	 */
	private $logger;

	/**
	 * Constructor: initialize plugin loader with logger instance
	 * depending on if configuration allows it
	 * @return void
	 */
	public function __construct()
	{

		if(Zend_Registry::isRegistered('logger')) $this->logger = Zend_Registry::get('logger');
	}

	function direct($message, $priority)
	{
		if ($this->logger) $this->logger->log($message, $priority);
	}

	function __call($name,$arguments) {

		if ($this->logger) {
			// Proxy over to existing methods of Zend_Log as well
			// as the shortcut methods (by __call in Zend_Log)
			if (method_exists($this->logger, $name))
			call_user_func_array ( array($this->logger, $name) , $arguments );
			else $this->logger->__call($name, $arguments);
		}
	}
}